//
//  MQVisitorTableViewController.swift
//  MQWeibo
//
//  Created by 毛强 on 15/12/28.
//  Copyright © 2015年 itheima. All rights reserved.
//

import UIKit

class MQVisitorTableViewController: UITableViewController {
    
    lazy var visitorView:MQVisitorView = MQVisitorView()
    var userLogin:Bool = MQUserAccountViewModel.sharedViewModel.userLogin
    
    
    override func loadView() {
        userLogin == true ? super.loadView():setupBaseUI()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    private func setupBaseUI(){
        view = visitorView
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: "registerButtonClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: "loginButtonClick")
        visitorView.registerButton.addTarget(self, action: "registerButtonClick", forControlEvents: .TouchUpInside)
        visitorView.loginButton.addTarget(self, action: "loginButtonClick", forControlEvents: .TouchUpInside)
    }
    
   @objc private func registerButtonClick(){
        print("注册")
        let vc = MQNavigationController(rootViewController: MQOAuthViewController())
        presentViewController(vc, animated: true, completion: nil)
    }
   @objc private func loginButtonClick(){
        print("登录")
        let vc = UINavigationController(rootViewController: MQOAuthViewController())
        presentViewController(vc, animated: true, completion: nil)
    }
}
